<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" class="user" name="user"><span>用户名</span>
    <input type="password" class="pass" name="mima"><span>密码</span>
    <input type="submit" value="登录" class="btn">
</body>
</html>
<!-- <script src="ajax.js"></script> -->
<script>
    function $(sel){return document.querySelector(sel)}
   $('.btn').onclick=function(){
    
		getMsg()
	}
   function getMsg(){
         
		var xhr=new XMLHttpRequest;
		xhr.open('GET','http://localhost:4000/user.json')
        xhr.send();
        console.log(1)
		xhr.onreadystatechange=function(){
            console.log(1)
			if(xhr.readyState===4){
                console.log(xhr.responseText)
                console.log(1)
				var res=xhr.responseText
                res=JSON.parse(res)
                console.log(res)
                console.log(1)
				// getname(res)
			}
		}
    }
	// function getname(data){
	// 	for(var i=0;i<data.length;i++){
	// 		if(data[i].name===data[i].city[0].name){
	// 			console.log(data[i].name)
	// 			console.log(data[i].city[0].area)
	// 		}
	// 	}
	// }
</script>